import http from '@/utils/request';

/**
 * 获取考试列表
 * @param {Object} params 查询参数
 * @returns {Promise}
 */
export const getExams = (params = {}) => {
  return http.get('/exam', params);
};

/**
 * 获取考试详情
 * @param {Number} id 考试ID
 * @returns {Promise}
 */
export const getExam = (id) => {
  return http.get(`/exam/${id}`);
};

/**
 * 报名考试
 * @param {Number} examId 考试ID
 * @returns {Promise}
 */
export const registerExam = (examId) => {
  return http.post(`/exam/${examId}/register`);
};

/**
 * 取消考试报名
 * @param {Number} examId 考试ID
 * @returns {Promise}
 */
export const cancelExamRegistration = (examId) => {
  return http.delete(`/exam/${examId}/register`);
};

/**
 * 获取我的考试列表
 * @returns {Promise}
 */
export const getMyExams = () => {
  return http.get('/exam/my');
};

/**
 * 获取我的考试成绩
 * @returns {Promise}
 */
export const getMyExamResults = () => {
  return http.get('/exam/my/results');
};